package com.example.myapp8_2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class AddBookActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_book);

        EditText et1 = (EditText) findViewById(R.id.tv_author);
        String author = et1.getText().toString();

        EditText et2 = (EditText) findViewById(R.id.tv_price);
        String price = et1.getText().toString();

        EditText et3 = (EditText) findViewById(R.id.tv_pages);
        String pages = et1.getText().toString();

        EditText et4 = (EditText) findViewById(R.id.tv_name);
        String name = et1.getText().toString();

        Button update = (Button) findViewById(R.id.add_to_db);
        update.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent(AddBookActivity.this,MainActivity.
                        class);
                Bundle bundle = new Bundle();
                bundle.putString("author",author);
                bundle.putString("price",price);
                bundle.putString("pages",pages);
                bundle.putString("name",name);
                intent.putExtras(bundle);

                startActivity(intent);


            }
        });


    }
}